package com.ali.order.message;

import com.ali.order.dto.OrderDTO;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.cloud.stream.annotation.StreamListener;
import org.springframework.messaging.handler.annotation.SendTo;
import org.springframework.stereotype.Component;


/**
 * @author Alistair.Chow
 */
@Component
@EnableBinding(StreamClient.class)
public class StreamReceiver {

    private static Logger logger = LoggerFactory.getLogger(StreamReceiver.class);

    /**
     * 接收OrderDTO
     * @param message
     */
    @StreamListener(value = StreamClient.INPUT2)
    @SendTo(StreamClient.INPUT3)
    public String process(OrderDTO message){
        logger.info(String.format("StreamReceiver: %s", message));
        return "received";
    }

    /**
     * 接收OrderDTO
     * @param message
     */
    @StreamListener(value = StreamClient.INPUT3)
    public void process2(String message){
        logger.info(String.format("StreamReceiver2: %s", message));
    }
}
